<template>
  <div class="toolbar colorMain">
    <div class="mt-10 mb-10">
      <el-form :inline="true" size="small">
        <el-form-item label="日期筛选"><date-picker v-model="queryFrom.time_range"/></el-form-item>
        <el-form-item label="充值区间" size="small"><money-range v-model="queryFrom.recharge_stage_list"/></el-form-item>
        <el-form-item label="渠道" size="small"><channel v-model="queryFrom.chn_filter_list"/></el-form-item>
        <el-form-item label="用户类型"><user-type v-model="queryFrom.user_type"/></el-form-item>
        <el-button size="small" type="primary" @click="sendQuery">提交</el-button>
      </el-form>
    </div>
    <div><el-button :loading="excelLoad" icon="el-icon-printer" style="float: right;margin: 0 0 10px 0" size="mini" type="success" @click="downExcel" >导出数据</el-button></div>
    <analyse-table v-if="showTable" :table-data="tableData" :key_mapper="key_mapper" :sortable = "['user_id', 'chn']" :min-width = "160" size="small" @sort-change="sortChange"/>
    <el-pagination :current-page.sync="page" :page-size="size" :total.sync="total" class="mt-10" layout="total, sizes, prev, pager, next, jumper" @current-change="currentChange" @size-change="handleSizeChange"/>
  </div>
</template>
<script>
import { pickTime } from '@/model/DateRange'
import { PayAbility } from '@/api/table'
import mixins from '@/model/mixins'

export default {
  name: 'Active',
  mixins: [mixins],
  data() {
    return {
      queryFrom: {
        chn_filter_list: [],
        recharge_stage_list: [],
        time_range: pickTime,
        user_type: ''
      },
      API: PayAbility,
      showTable: true
    }
  },
  watch: {
    tableData() {
      this.showTable = false
      this.$nextTick(() => (
        this.showTable = true
      ))
    }
  }
}
</script>
